package com.utcs.modules.resource.basic.entity;

import com.utcs.common.persistence.DataEntity;
import com.utcs.common.persistence.TreeEntity;

/**
 * Created by Fly on 2017/5/23.
 * 用户实体类
 */
public class User extends DataEntity<User> {

    private static final long serialVersionUID = 1L;

    private String name;
    private String password;
    private String code;
    private Department department;

    public User() {
    }

    public User(Integer id, String name) {
        super(id);
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    public boolean isAdmin(){
        return isAdmin(this.id);
    }

    public static boolean isAdmin(Integer id){
        return id != null && 1 == id;
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", password='" + password + '\'' +
                ", code='" + code + '\'' +
                ", department=" + department +
                '}';
    }
}
